package Test8;

public class Ticket implements Runnable {
	// 共100票
	int ticket = 100;

	@Override
	public void run() {
		// 模拟卖票
		while (true) {
			abc();
		}
	}

	private synchronized void abc() {
		if (ticket > 0) {
			// 模拟选坐的操作
			try {
				Thread.sleep(1);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			System.out.println(Thread.currentThread().getName() + "正在卖票:" + ticket--);
		}
	}
}
